import TextArea from "antd/es/input/TextArea";
import {CommonComponentProps} from "../../../../components/editor/interface.ts";
import {useDrag} from "react-dnd";
import FormItem from "antd/es/form/FormItem";
import {CSSProperties} from "react";
import {removeSetter} from "../../../utils/removeSetter.ts";
import {MoveDrop} from "../../../hooks/useMoveDrop.tsx";

export interface TextAreaProps extends CommonComponentProps {
    id: number;
    name: string;
    styles?: CSSProperties;
    parentId: number;
    children?: any;
    placeholder:string
    maxLength:number
    disabled:boolean
    showCount:boolean
    autoSize:boolean
    allowClear:boolean
}
const TextAreaDev =(props:TextAreaProps) => {
    const { id,name,styles} = props

    const [_,drag] = useDrag({
        type:"TextArea",
        item:{
            id,
            type:name,
            dragType:"move",
        }
    })
    const ComponentProps = removeSetter({...props},["children","parentId"])

    return (
            <div className={'relative'}  data-component-id={id} ref={drag} style={styles}>
                <MoveDrop key={name} dropComponentId={id} parentId={props.parentId}  />
                <FormItem>
                    <FormItem label={props.label} name={props.name} rules={props.rule} style={{margin: "0",...styles}}>
                        <TextArea {...ComponentProps} />
                    </FormItem>
                </FormItem>
            </div>

    );
};

export default TextAreaDev;